package com.sz.ruichar.controller.beans;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sz.ruichar.entity.beans.TScoreGoods;
import com.sz.ruichar.interfs.beans.ITScoreGoodsService;
import com.sz.ruichar.service.entity.model.result.ResultData;

@RestController
@RequestMapping("/goods")
public class ScoreGoodController 
{
    private static Logger log = LoggerFactory.getLogger(ScoreGoodController.class);
    @Autowired
    private ITScoreGoodsService scoreGoodsService;
    
    @PostMapping(value="rechangeGood")
    public ResultData rechangeGood(@RequestBody Map<String,Object> param)
    {
    	if(null == param || param.isEmpty()){
    		return ResultData.error("error param");
    	}
    	try {
    		return scoreGoodsService.rechangeGood(param);
		} catch (Exception e) {
			log.info("===========积分兑换错误：{}=================",e.getMessage());
			return ResultData.error(e.getMessage());
		}
    }
    
    @GetMapping(value="getGoodList")
    public  ResultData getGoodList(){
    	List<TScoreGoods> goodList = scoreGoodsService.selectByMap(null);
    	return ResultData.success(goodList);
    }
    
    
    
    
    
    
    
}
